<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>百度地图API-批量地址解译</title>
    <link href="css/Baidu.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        body,
        html,
        #allmap {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
            font-family: "微软雅黑";
        }
    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?type=webgl&v=1.0&ak=PPDuSsbu2kdqP0o7WzvXQn1dB0NNzu4l"></script>
    <script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
    <title>批量转换</title>
</head>

<body>
    <div id="allmap"></div>
</body>

<script type="text/javascript">
    var x_pi = 3.14159265358979324 * 3000.0 / 180.0;
    var xdata = [114.216857, 114.218206, 114.216243, 114.217293, 114.217343, 114.215164, 114.221804, 114.221119, 114.221523, 114.220750];
    var ydata = [34.766955, 34.803927, 34.808812, 34.815161, 34.821077, 34.821417, 34.841082, 34.834151, 34.834187, 34.832520];

    function bd_encrypt() {
        for (var i = 0; i <= 10; i++) {
            // var x = gg_lon;
            // var y = gg_lat;
            var x = xdata[i];
            var y = ydata[i];
            var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
            var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
            bd_lon = z * Math.cos(theta) + 0.0065;
            bd_lat = z * Math.sin(theta) + 0.006;
            console.log(bd_lon + ";" + bd_lat);
        }
    }

    function bd_decrypt() {
        for (var i = 0; i < 10; i++) {
            // var x = bd_lon - 0.0065;
            // var y = bd_lat - 0.006;
            var x = xdata[i];
            var y = ydata[i];
            var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
            var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
            gg_lon = z * Math.cos(theta);
            gg_lat = z * Math.sin(theta);
            console.log(gg_lon + ";" + gg_lat)

        }
    }
    bd_encrypt();
    bd_decrypt();
</script>

</html>